package controller;

import entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Author：汤小洋
 * Date：2023-12-15 14:21
 * Description：<描述>
 */
// @Controller
// @ResponseBody
@RestController // @RestController = @Controller + @ResponseBody
// @CrossOrigin
public class AjaxController {

    // @ResponseBody
    @RequestMapping("/ajax1")
    public User ajax1(){
        System.out.println("AjaxController.ajax1......");

        User user = new User(1, "tom", "123", 18, null, new Date());
        return user; // 引入jackson依赖后，会自动将对象转换为json字符串
    }

}
